package com.demo.lesson02.service;

import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * 自定义此处实现UserDetailsService接口，则会覆盖 spring security 默认的本地 UserDetailsService(InMemoryUserDetailsManager)
 */
@Service
public class InMemoryUserDetailsServiceImpl implements UserDetailsService {
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        return User.withUsername("test")
                // {noop} 表示密码不加密
                .password("{noop}4321")
                .build();
    }
}
